import {ref,toRefs,onMounted} from '@vue/composition-api'
import {Dialog,Toast} from 'vant'
export default function ($router,cb){
    //取消
      const onCancel=({message='确定要取消该活动吗',id}={message:'确定要取消该活动吗'})=> {
          Dialog
          .confirm({
            title: "提示",
            message: "确定要取消该活动吗？",
            confirmButtonText: "确定",
          })
          .then(() => {
              cb(id)
              .then((res) => {
                if (res.code === 0) {
                  $router.go(0);
                    Toast("操作成功");
                } else {
                    Toast(res.msg);
                }
              })
              .catch((err) => {
                  Toast("操作失败，请稍后重试！");
              });
          })
          .catch(() => {
            // on cancel
          });
      }
      return {
          onCancel
      }
}
